<?php

class iSpringResourceManager extends ResourceManager
{
    public function __construct( ICache $cache, Substitutions $substitutions )
    {
        $this->cache = $cache;
        $this->AddResource( new NewsResource($this) );
        $this->AddResource( new TestimonialsResource($this) );
        $this->AddResource( new PagesResource($this, $substitutions) );
        $this->AddResource( new ArticlesResource($this) );
        $this->AddResource( new FeaturesResource($this) );
        $this->AddResource( new SidebarsResource($this) );
        $this->AddResource( new SearchPagesResource($this) );
        $this->AddResource( new PageUrlsResource($this) );
        $this->AddResource( new ThemesResource($this) );
    }

    public function GetBlogNews()
    {
        return $this->GetData( NewsResource::ID );
    }

    public function GetTestimonials()
    {
        return $this->GetData( TestimonialsResource::ID );
    }

    public function GetPages()
    {
        return $this->GetData( PagesResource::ID );
    }

    public function GetSearchPages()
    {
        return $this->GetData( SearchPagesResource::ID );
    }

    public function GetUrls()
    {
        return $this->GetData( PageUrlsResource::ID );
    }

    public function GetArticles()
    {
        return $this->GetData( ArticlesResource::ID );
    }

    public function GetFeatures()
    {
        return $this->GetData( FeaturesResource::ID );
    }

    public function GetSidebarsInfo()
    {
        return $this->GetData( SidebarsResource::ID );
    }
    public function GetThemes()
    {
        return $this->GetData( ThemesResource::ID );
    }
    
    /**
     * Returns ThemeInfo by theme id. If theme not found, function returns default theme or empty theme.
     *
     * @param string $themeID
     * @return ThemeInfo
     */
    public function GetThemesByID( $themeID )
    {
        $themes = $this->GetThemes();
        if ( isset( $themes[$themeID] ) )
        {
            return $themes[$themeID];
        }
        
        if ( isset( $themes[DEFAULT_THEME_ID] ) )
        {
            return $themes[DEFAULT_THEME_ID];
        }
        
        return new ThemeInfo();
    }
}

?>
